package cn.lijigou.shopping;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.lijigou.shopping.service.MSystem;

 




import android.app.Activity;
import android.app.SearchManager.OnCancelListener;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class AllCiTies extends Activity implements OnItemClickListener,OnScrollListener,OnClickListener{
    /** Called when the activity is first created. */
	private MyListAdapter  adapter;  
    private String[] stringArry;
    private String[] pingYingArry;
    private Map<String, String> sortMap=new HashMap<String, String>();
    private List<TextView> textViews=new ArrayList<TextView>();
	private ArrayList<String> webNameArr;     
    private WindowManager windowManager;   
    private TextView txtOverlay;   //��4����WindowManager����ʾ��ʾ�ַ�  
    private Handler handler;     
    private DisapearThread disapearThread;     
    private int scrollState;  //���״̬  
    private ListView list;
    private String from;
	    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE); 
        setContentView(R.layout.allcity);
        from=this.getIntent().getStringExtra("from");
        TextView back = (TextView) this.findViewById(R.id.title_btn_left);
		back.setBackgroundResource(R.drawable.title_back_normal);
//		back.setBackgroundResource(R.drawable.title_btn);c
		this.findViewById(R.id.titleRightView).setVisibility(View.GONE);    
		this.findViewById(R.id.titleLeftView).setOnClickListener(this);
        
        pingYingArry=new String[]{"北京市","天津市","石家庄市","辛集市","藁城市","晋州市","新乐市","鹿泉市","唐山市","遵化市","丰南市","迁安市","秦皇岛市","邯郸市","武安市","邢台市",
	   			"南宫市","沙河市","保定市","涿州市","定州市","安国市","高碑店市","张家口市","承德市","沧州市","泊头市","任丘市","黄骅市","河间市","廊坊市","霸州市","三河市","衡水市","冀州市",
	   			"深州市","太原市","古交市","大同市","阳泉市","长治市","潞城市","晋城市","高平市","朔州市","忻州市","原平市","吕梁市","孝义市","汾阳市","晋中市","榆次市","介休市","临汾市",
	   			"临汾市","侯马市","霍州市","运城市","运城市","永济市","河津市","呼和浩特市","包头市","乌海市","赤峰市","呼伦贝尔市","海拉尔市","满洲里市","扎兰屯市","牙克石市","根河市",
	   			"额尔古纳市","乌兰浩特市","阿尔山市","通辽市","霍林郭勒市","二连浩特市","锡林浩特市","集宁市","丰镇市","东胜市","临河市","沈阳市","新民市","大连市","瓦房店市","普兰店市","庄河市",
	   			"鞍山市","海城市","抚顺市","本溪市","丹东市","东港市","凤城市","锦州市","凌海市","北宁市","营口市","盖州市","大石桥市","阜新市","辽阳市","灯塔市","盘锦市","铁岭市","铁法市","开原市",
	   			"朝阳市","北票市","凌源市","葫芦岛市","兴城市","长春市","九台市","榆树市","德惠市","吉林市","蛟河市","桦甸市","舒兰市","磐石市","四平市","公主岭市","双辽市","辽源市","通化市",
	   			"梅河口市","集安市","白山市","临江市","松原市","白城市","洮南市","大安市","延吉市","图们市","敦化市","珲春市","龙井市","和龙市","哈尔滨市","双城市","尚志市","五常市","齐齐哈尔市",
	   			"讷河市","鸡西市","虎林市","密山市","鹤岗市","双鸭山市","大庆市","伊春市","铁力市","同江市","富锦市","七台河市","牡丹江市","绥芬河市","海林市","宁安市","穆棱市","黑河市","北安市",
	   			"五大连池市","绥化市","绥化市","安达市","肇东市","海伦市","上海市","南京市","无锡市","江阴市","宜兴市","锡山市","徐州市","新沂市","邳州市","常州市","溧阳市","金坛市","武进市",
	   			"苏州市","常熟市","张家港市","昆山市","吴江市","太仓市","吴县市","南通市","启东市","如皋市","通州市","海门市","连云港市","淮阴市","淮安市","盐城市","东台市","大丰市","扬州市",
	   			"仪征市","高邮市","江都市","镇江市","丹阳市","扬中市","句容市","泰州市","兴化市","靖江市","泰兴市","姜堰市","宿迁市","杭州市","萧山市","建德市","富阳市","余杭市","临安市","宁波市",
	   			"余姚市","慈溪市","奉化市","温州市","瑞安市","乐清市","嘉兴市","海宁市","平湖市","桐乡市","湖州市","绍兴市","诸暨市","上虞市","嵊州市","金华市","兰溪市","义乌市","东阳市","永康市",
	   			"衢州市","江山市","舟山市","台州市","温岭市","临海市","丽水市","丽水市","龙泉市","合肥市","芜湖市","蚌埠市","淮南市","马鞍山市","淮北市","铜陵市","安庆市","桐城市","黄山市","滁州市",
	   			"天长市","明光市","阜阳市","界首市","宿州市","六安市","宣城市","宁国市","巢湖市","池州市","福州市","福清市","长乐市","厦门市","宁德市","福安市","福鼎市","莆田市","泉州市","石狮市",
	   			"晋江市","南安市","漳州市","龙海市","漳平市","三明市","永安市","南平市","邵武市","武夷山市","建瓯市","建阳市","南昌市","景德镇市","乐平市","萍乡市","九江市","瑞昌市","新余市",
	   			"鹰潭市","贵溪市","赣州市","瑞金市","南康市","宜春市","宜春市","丰城市","樟树市","高安市","上饶市","上饶市","德兴市","吉安市","吉安市","井冈山市","抚州市","临川市","济南市","章丘市",
	   			"青岛市","胶州市","即墨市","平度市","胶南市","莱西市","淄博市","枣庄市","滕州市","东营市","烟台市","龙口市","莱阳市","莱州市","蓬莱市","招远市","栖霞市","海阳市","潍坊市","青州市",
	   			"诸城市","寿光市","安丘市","高密市","昌邑市","济宁市","曲阜市","兖州市","邹城市","泰安市","新泰市","肥城市","威海市","文登市","荣成市","乳山市","日照市","莱芜市","临沂市","德州市",
	   			"乐陵市","禹城市","聊城市","临清市","滨州市","菏泽市","郑州市","巩义市","荥阳市","新密市","新郑市","登封市","开封市","洛阳市","偃师市","平顶山市","舞钢市","汝州市","安阳市","林州市",
	   			"鹤壁市","新乡市","卫辉市","辉县市","焦作市","沁阳市","孟州市","濮阳市","许昌市","禹州市","长葛市","漯河市","三门峡市","义马市","灵宝市","南阳市","州市","商丘市","永城市","信阳市",
	   			"周口市","周口市","项城市","驻马店市","济源市","武汉市","黄石市","大冶市","十堰市","丹江口市","宜昌市","宜都市","当阳市","枝江市","襄樊市","老河口市","枣阳市","宜城市","鄂州市",
	   			"荆门市","钟祥市","孝感市","应城市","安陆市","汉川市","荆州市","石首市","洪湖市","松滋市","黄冈市","麻城市","武穴市","咸宁市","赤壁市","恩施市","利川市","仙桃市",
	   			"潜江市","天门市","长沙市","浏阳市","株洲市","醴陵市","湘潭市","湘乡市","韶山市","衡阳市","耒阳市","常宁市","邵阳市","武冈市","岳阳市","汨罗市","临湘市","常德市",
	   			"津市市","张家界市","益阳市","沅江市","郴州市","资兴市","永州市","怀化市","洪江市","娄底市","冷水江市","涟源市","吉首市","广州市","番禺市","花都市","增城市","从化市",
	   			"韶关市","乐昌市","南雄市","深圳市","珠海市","汕头市","佛山市","江门市","台山市","新会市","开平市","鹤山市","恩平市","湛江市","廉江市","雷州市","吴川市","茂名市",
	   			"高州市","化州市","信宜市","肇庆市","高要市","四会市","惠州市","惠阳市","梅州市","兴宁市","汕尾市","陆丰市","河源市","阳江市","阳春市","清远市","英德市","连州市",
	   			"东莞市","中山市","潮州市","揭阳市","普宁市","云浮市","罗定市","南宁市","柳州市","桂林市","梧州市","岑溪市","北海市","防城港市","东兴市","钦州市","贵港市","桂平市",
	   			"玉林市","北流市","崇左市","凭祥市","来宾市","合山市","贺州市","百色市","河池市","宜州市","琼海市","儋州市","五指山市","文昌市","万宁市","东方市","海口市","三亚市",
	   			"重庆市","江津市","合川市","永川市","南川市","成都市","都江堰市","彭州市","邛崃市","崇州市","自贡市","攀枝花市","泸州市","德阳市","广汉市","什邡市","绵竹市","绵阳市",
	   			"江油市","广元市","遂宁市","内江市","乐山市","峨眉山市","南充市","阆中市","宜宾市","广安市","华莹市","达川市","万源市","雅安市","西昌市","巴中市","资阳市","简阳市",
	   			"贵阳市","清镇市","六盘水市","遵义市","赤水市","仁怀市","铜仁市","兴义市","毕节市","安顺市","凯里市","都匀市","福泉市","昆明市","安宁市","曲靖市","宣威市","玉溪市",
	   			"昭通市","楚雄市","个旧市","开远市","思茅市","思茅市","景洪市","大理市","保山市","畹町市","瑞丽市","潞西市","丽江市","拉萨市","日喀则市","西安市","铜川市","宝鸡市",
	   			"咸阳市","兴平市","渭南市","韩城市","华阴市","延安市","汉中","安康市","商州市","榆林市","兰州市","嘉峪关市","金昌市","白银市","天水市","玉门市","酒泉市","敦煌市",
	   			"张掖市","武威市","平凉市","西峰市","临夏市","合作市","西宁市","格尔木市","德令哈市","银川市","灵武市","石嘴山市","吴忠市","青铜峡市","中卫市","乌鲁木齐市",
	   			"克拉玛依市","吐鲁番市","哈密市","昌吉市","阜康市","博乐市","库尔勒市","阿克苏市","阿图什市","喀什市","和田市","奎屯市","伊宁市","塔城市","乌苏市","阿勒泰市",
	   			"石河子市","阿拉尔市","图木舒市","五家渠市"};    
	        
	   	
	   	 
	   	
	   stringArry=new String[]{"bei jing shi ","tian jin shi ","shi jia zhuang shi ","xin ji shi ","gao cheng shi ","jin zhou shi ","xin le shi ","lu quan shi ","tang shan shi ","zun hua shi ","feng nan shi ","qian an shi ","qin huang dao shi ","han dan shi ","wu an shi ","xing tai shi ",
	   			"nan gong shi ","sha he shi ","bao ding shi ","zhuo zhou shi ","ding zhou shi ","an guo shi ","gao bei dian shi ","zhang jia kou shi ","cheng de shi ","cang zhou shi ","bo tou shi ","ren qiu shi ","huang 骅shi ","he jian shi ","lang fang shi ","ba zhou shi ","san he shi ","heng shui shi ","ji zhou shi ",
	   			"shen zhou shi ","tai yuan shi ","gu jiao shi ","da tong shi ","yang quan shi ","chang zhi shi ","lu cheng shi ","jin cheng shi ","gao ping shi ","shuo zhou shi ","xin zhou shi ","yuan ping shi ","lv liang shi ","xiao yi shi ","fen yang shi ","jin zhong shi ","yu ci shi ","jie xiu shi ","lin fen shi ",
	   			"lin fen shi ","hou ma shi ","huo zhou shi ","yun cheng shi ","yun cheng shi ","yong ji shi ","he jin shi ","hu he hao te shi ","bao tou shi ","wu hai shi ","chi feng shi ","hu lun bei er shi ","hai la er shi ","man zhou li shi ","zha lan tun shi ","ya ke shi shi ","gen he shi ",
	   			"e er gu na shi ","wu lan hao te shi ","a er shan shi ","tong liao shi ","huo lin guo le shi ","er lian hao te shi ","xi lin hao te shi ","ji ning shi ","feng zhen shi ","dong sheng shi ","lin he shi ","shen yang shi ","xin min shi ","da lian shi ","wa fang dian shi ","pu lan dian shi ","zhuang he shi ",
	   			"an shan shi ","hai cheng shi ","fu shun shi ","ben xi shi ","dan dong shi ","dong gang shi ","feng cheng shi ","jin zhou shi ","ling hai shi ","bei ning shi ","ying kou shi ","gai zhou shi ","da shi qiao shi ","fu xin shi ","liao yang shi ","deng ta shi ","pan jin shi ","tie ling shi ","tie fa shi ","kai yuan shi ",
	   			"chao yang shi ","bei piao shi ","ling yuan shi ","hu lu dao shi ","xing cheng shi ","chang chun shi ","jiu tai shi ","yu shu shi ","de hui shi ","ji lin shi ","jiao he shi ","hua dian shi ","shu lan shi ","pan shi shi ","si ping shi ","gong zhu ling shi ","shuang liao shi ","liao yuan shi ","tong hua shi ",
	   			"mei he kou shi ","ji an shi ","bai shan shi ","lin jiang shi ","song yuan shi ","bai cheng shi ","tao nan shi ","da an shi ","yan ji shi ","tu men shi ","dun hua shi ","hui chun shi ","long jing shi ","he long shi ","ha er bin shi ","shuang cheng shi ","shang zhi shi ","wu chang shi ","qi qi ha er shi ",
	   			"nehe shi ","ji xi shi ","hu lin shi ","mi shan shi ","he gang shi ","shuang ya shan shi ","da qing shi ","yi chun shi ","tie li shi ","tong jiang shi ","fu jin shi ","qi tai he shi ","mu dan jiang shi ","sui fen he shi ","hai lin shi ","ning an shi ","mu leng shi ","hei he shi ","bei an shi ",
	   			"wu da lian chi shi ","sui hua shi ","sui hua shi ","an da shi ","zhao dong shi ","hai lun shi ","shang hai shi ","nan jing shi ","wu xi shi ","jiang yin shi ","yi xing shi ","xi shan shi ","xu zhou shi ","xin yi shi ","pi zhou shi ","chang zhou shi ","li yang shi ","jin tan shi ","wu jin shi ",
	   			"su zhou shi ","chang shu shi ","zhang jia gang shi ","kun shan shi ","wu jiang shi ","tai cang shi ","wu xian shi ","nan tong shi ","qi dong shi ","ru gao shi ","tong zhou shi ","hai men shi ","lian yun gang shi ","huai yin shi ","huai an shi ","yan cheng shi ","dong tai shi ","da feng shi ","yang zhou shi ",
	   			"yi zheng shi ","gao you shi ","jiang du shi ","zhen jiang shi ","dan yang shi ","yang zhong shi ","ju rong shi ","tai zhou shi ","xing hua shi ","jing jiang shi ","tai xing shi ","jiang yan shi ","su qian shi ","hang zhou shi ","xiao shan shi ","jian de shi ","fu yang shi ","yu hang shi ","lin an shi ","ning bo shi ",
	   			"yu yao shi ","ci xi shi ","feng hua shi ","wen zhou shi ","rui an shi ","le qing shi ","jia xing shi ","hai ning shi ","ping hu shi ","tong xiang shi ","hu zhou shi ","shao xing shi ","zhu ji shi ","shang yu shi ","sheng zhou shi ","jin hua shi ","lan xi shi ","yi wu shi ","dong yang shi ","yong kang shi ",
	   			"qu zhou shi ","jiang shan shi ","zhou shan shi ","tai zhou shi ","wen ling shi ","lin hai shi ","li shui shi ","li shui shi ","long quan shi ","he fei shi ","wu hu shi ","bang bu shi ","huai nan shi ","ma an shan shi ","huai bei shi ","tong ling shi ","an qing shi ","tong cheng shi ","huang shan shi ","chu zhou shi ",
	   			"tian chang shi ","ming guang shi ","fu yang shi ","jie shou shi ","su zhou shi ","liu an shi ","xuan cheng shi ","ning guo shi ","chao hu shi ","chi zhou shi ","fu zhou shi ","fu qing shi ","chang le shi ","xia men shi ","ning de shi ","fu an shi ","fu ding shi ","pu tian shi ","quan zhou shi ","shi shi shi ",
	   			"jin jiang shi ","nan an shi ","zhang zhou shi ","long hai shi ","zhang ping shi ","san ming shi ","yong an shi ","nan ping shi ","shao wu shi ","wu yi shan shi ","jian ou shi ","jian yang shi ","nan chang shi ","jing de zhen shi ","le ping shi ","ping xiang shi ","jiu jiang shi ","rui chang shi ","xin yu shi ",
	   			"ying tan shi ","gui xi shi ","gan zhou shi ","rui jin shi ","nan kang shi ","yi chun shi ","yi chun shi ","feng cheng shi ","zhang shu shi ","gao an shi ","shang rao shi ","shang rao shi ","de xing shi ","ji an shi ","ji an shi ","jing gang shan shi ","fu zhou shi ","lin chuan shi ","ji nan shi ","zhang qiu shi ",
	   			"qing dao shi ","jiao zhou shi ","ji mo shi ","ping du shi ","jiao nan shi ","lai xi shi ","zi bo shi ","zao zhuang shi ","teng zhou shi ","dong ying shi ","yan tai shi ","long kou shi ","lai yang shi ","lai zhou shi ","peng lai shi ","zhao yuan shi ","qi xia shi ","hai yang shi ","wei fang shi ","qing zhou shi ",
	   			"zhu cheng shi ","shou guang shi ","an qiu shi ","gao mi shi ","chang yi shi ","ji ning shi ","qu fu shi ","yan zhou shi ","zou cheng shi ","tai an shi ","xin tai shi ","fei cheng shi ","wei hai shi ","wen deng shi ","rong cheng shi ","ru shan shi ","ri zhao shi ","lai wu shi ","lin yi shi ","de zhou shi ",
	   			"le ling shi ","yu cheng shi ","liao cheng shi ","lin qing shi ","bin zhou shi ","he ze shi ","zheng zhou shi ","gong yi shi ","ying yang shi ","xin mi shi ","xin zheng shi ","deng feng shi ","kai feng shi ","luo yang shi ","yan shi shi ","ping ding shan shi ","wu gang shi ","ru zhou shi ","an yang shi ","lin zhou shi ",
	   			"he bi shi ","xin xiang shi ","wei hui shi ","hui xian shi ","jiao zuo shi ","qin yang shi ","meng zhou shi ","pu yang shi ","xu chang shi ","yu zhou shi ","chang ge shi ","luo he shi ","san men xia shi ","yi ma shi ","ling bao shi ","nan yang shi ","zhou shi ","shang qiu shi ","yong cheng shi ","xin yang shi ",
	   			"zhou kou shi ","zhou kou shi ","xiang cheng shi ","zhu ma dian shi ","ji yuan shi ","wu han shi ","huang shi shi ","da ye shi ","shi yan shi ","dan jiang kou shi ","yi chang shi ","yi du shi ","dang yang shi ","zhi jiang shi ","xiang fan shi ","lao he kou shi ","zao yang shi ","yi cheng shi ","e zhou shi ",
	   			"jing men shi ","zhong xiang shi ","xiao gan shi ","ying cheng shi ","an lu shi ","han chuan shi ","jing zhou shi ","shi shou shi ","hong hu shi ","song zi shi ","huang gang shi ","ma cheng shi ","wu xue shi ","xian ning shi ","chi bi shi ","en shi shi ","li chuan shi ","xian tao shi ",
	   			"qian jiang shi ","tian men shi ","chang sha shi ","liu yang shi ","zhu zhou shi ","li ling shi ","xiang tan shi ","xiang xiang shi ","shao shan shi ","heng yang shi ","lei yang shi ","chang ning shi ","shao yang shi ","wu gang shi ","yue yang shi ","mi luo shi ","lin xiang shi ","chang de shi ",
	   			"jin shi shi ","zhang jia jie shi ","yi yang shi ","yuan jiang shi ","chen zhou shi ","zi xing shi ","yong zhou shi ","huai hua shi ","hong jiang shi ","lou di shi ","leng shui jiang shi ","lian yuan shi ","ji shou shi ","guang zhou shi ","fan yu shi ","hua du shi ","zeng cheng shi ","cong hua shi ",
	   			"shao guan shi ","le chang shi ","nan xiong shi ","shen zhen shi ","zhu hai shi ","shan tou shi ","fo shan shi ","jiang men shi ","tai shan shi ","xin hui shi ","kai ping shi ","he shan shi ","en ping shi ","zhan jiang shi ","lian jiang shi ","lei zhou shi ","wu chuan shi ","mao ming shi ",
	   			"gao zhou shi ","hua zhou shi ","xin yi shi ","zhao qing shi ","gao yao shi ","si hui shi ","hui zhou shi ","hui yang shi ","mei zhou shi ","xing ning shi ","shan wei shi ","lu feng shi ","he yuan shi ","yang jiang shi ","yang chun shi ","qing yuan shi ","ying de shi ","lian zhou shi ",
	   			"dong guan shi ","zhong shan shi ","chao zhou shi ","jie yang shi ","pu ning shi ","yun fu shi ","luo ding shi ","nan ning shi ","liu zhou shi ","gui lin shi ","wu zhou shi ","cen xi shi ","bei hai shi ","fang cheng gang shi ","dong xing shi ","qin zhou shi ","gui gang shi ","gui ping shi ",
	   			"yu lin shi ","bei liu shi ","chong zuo shi ","ping xiang shi ","lai bin shi ","he shan shi ","he zhou shi ","bai se shi ","he chi shi ","yi zhou shi ","qiong hai shi ","dan zhou shi ","wu zhi shan shi ","wen chang shi ","wan ning shi ","dong fang shi ","hai kou shi ","san ya shi ",
	   			"zhong qing shi ","jiang jin shi ","he chuan shi ","yong chuan shi ","nan chuan shi ","cheng du shi ","du jiang yan shi ","peng zhou shi ","qiong lai shi ","chong zhou shi ","zi gong shi ","pan zhi hua shi ","lu zhou shi ","de yang shi ","guang han shi ","shi fang shi ","mian zhu shi ","mian yang shi ",
	   			"jiang you shi ","guang yuan shi ","sui ning shi ","nei jiang shi ","le shan shi ","e mei shan shi ","nan chong shi ","lang zhong shi ","yi bin shi ","guang an shi ","hua ying shi ","da chuan shi ","wan yuan shi ","ya an shi ","xi chang shi ","ba zhong shi ","zi yang shi ","jian yang shi ",
	   			"gui yang shi ","qing zhen shi ","liu pan shui shi ","zun yi shi ","chi shui shi ","ren huai shi ","tong ren shi ","xing yi shi ","bi jie shi ","an shun shi ","kai li shi ","du yun shi ","fu quan shi ","kun ming shi ","an ning shi ","qu jing shi ","xuan wei shi ","yu xi shi ",
	   			"zhao tong shi ","chu xiong shi ","ge jiu shi ","kai yuan shi ","si mao shi ","si mao shi ","jing hong shi ","da li shi ","bao shan shi ","wan ding shi ","rui li shi ","lu xi shi ","li jiang shi ","la sa shi ","ri ka ze shi ","xi an shi ","tong chuan shi ","bao ji shi ",
	   			"xian yang shi ","xing ping shi ","wei nan shi ","han cheng shi ","hua yin shi ","yan an shi ","han zhong ","an kang shi ","shang zhou shi ","yu lin shi ","lan zhou shi ","jia yu guan shi ","jin chang shi ","bai yin shi ","tian shui shi ","yu men shi ","jiu quan shi ","dun huang shi ",
	   			"zhang ye shi ","wu wei shi ","ping liang shi ","xi feng shi ","lin xia shi ","he zuo shi ","xi ning shi ","ge er mu shi ","de ling ha shi ","yin chuan shi ","ling wu shi ","shi zui shan shi ","wu zhong shi ","qing tong xia shi ","zhong wei shi ","wu lu mu qi shi ",
	   			"ke la ma yi shi ","tu lu fan shi ","ha mi shi ","chang ji shi ","fu kang shi ","bo le shi ","ku er le shi ","a ke su shi ","a tu shi shi ","ka shi shi ","he tian shi ","kui tun shi ","yi ning shi ","ta cheng shi ","wu su shi ","a le tai shi ",
	   			"shi he zi shi ","a la er shi ","tu mu shu shi ","wu jia qu shi "}; 
 
        for(int i=0;i<pingYingArry.length;i++){
        	sortMap.put(stringArry[i], pingYingArry[i]);
        	
        }
        ((TextView) this.findViewById(R.id.text_center)).setText("所有城市");
        
        txtOverlay = (TextView) LayoutInflater.from(this).inflate(R.layout.list_popup_char_hint, null);     
        // Ĭ������Ϊ���ɼ�     
        txtOverlay.setVisibility(View.INVISIBLE);    
        //����WindowManager  
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(LayoutParams.WRAP_CONTENT,     
        LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_APPLICATION,     
        //����Ϊ�޽���״̬  
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,   
        //��͸��Ч��  
        PixelFormat.TRANSLUCENT);     
        windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);     
        windowManager.addView(txtOverlay, lp);   
          
        handler = new Handler();     
        disapearThread = new DisapearThread();    
  
        Arrays.sort(stringArry,String.CASE_INSENSITIVE_ORDER); //��Сд�����  
        webNameArr = new ArrayList<String>();       
        for (int i = 0; i < stringArry.length; i++) {     
            webNameArr.add(stringArry[i]);        
        }     
         
          
        list = (ListView)this.findViewById(R.id.list); //jϵ��ListView  
          
        adapter = new MyListAdapter(this);   
        list.setAdapter(adapter);//�������������Activity���а�  
        list.setOnScrollListener(this);   
        list.setOnItemClickListener(this);
          
        
        ((TextView)this.findViewById(R.id.all1)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all2)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all3)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all4)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all5)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all6)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all7)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all8)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all9)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all10)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all11)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all12)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all13)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all14)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all15)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all16)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all17)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all18)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all19)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all20)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all21)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all22)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all23)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all24)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all25)).setOnClickListener(this);
        ((TextView)this.findViewById(R.id.all26)).setOnClickListener(this);
        
        
        
        
        
        
    }

    private class DisapearThread implements Runnable {     
        public void run() {     
            // ������1.5s�ڣ��û��ٴ��϶�ʱ��ʾ����ִ���������     
            if (scrollState == ListView.OnScrollListener.SCROLL_STATE_IDLE) {     
                txtOverlay.setVisibility(View.INVISIBLE);     
            }     
        }     
    }  
    
    public final  class ViewHolder {     
        public TextView firstCharHintTextView;     
        public TextView nameTextView;     
        public TextView urlTextView;     
        public ImageView imgView;     
    }     
    private class MyListAdapter extends BaseAdapter {     
        private LayoutInflater inflater;     
        public MyListAdapter(Context context) {     
            this.inflater = LayoutInflater.from(context);     
        }     
        public int getCount() {     
            return  webNameArr.size();     
        }     
        public Object getItem(int position) {     
            return webNameArr.get(position);     
        }     
        public long getItemId(int position) {     
            return position;     
        }     
        public View getView(final int position, View convertView, ViewGroup parent) {     
            ViewHolder holder = null;   
            if (convertView == null) {     
                convertView = inflater.inflate(R.layout.list_item, null);     
                holder = new ViewHolder();     
                holder.firstCharHintTextView = (TextView) convertView.findViewById(R.id.text_first_char_hint);     
                holder.nameTextView = (TextView) convertView.findViewById(R.id.content);       
                convertView.setTag(holder);     
            } else {     
                holder = (ViewHolder) convertView.getTag();     
            }     
            holder.nameTextView.setText(sortMap.get(webNameArr.get(position)));        
            int idx = position - 1;     
            //�ж�ǰ��Item�Ƿ�ƥ�䣬���ƥ�������ò���ʾ��ƥ����ȡ��  
            char previewChar = idx >= 0 ? stringArry[idx].charAt(0) : ' ';     
            char currentChar = stringArry[position].charAt(0);   
            //��Сд�ַ�ת��Ϊ��д�ַ�  
            char newPreviewChar = Character.toUpperCase(previewChar);    
            char newCurrentChar = Character.toUpperCase(currentChar);    
            if (newCurrentChar != newPreviewChar) {     
                holder.firstCharHintTextView.setVisibility(View.VISIBLE);     
                holder.firstCharHintTextView.setText(String.valueOf(newCurrentChar));     
            } else {     
                // �˶δ��벻��ȱ��ʵ��һ��CurrentView�󣬻ᱻ��θ�ֵ����ֻ�����һ�θ�ֵ��position����ȷ     
                holder.firstCharHintTextView.setVisibility(View.GONE);     
            }     
            return convertView;     
        }     
    }    
    
	public void onScroll(AbsListView view, int firstVisibleItem,
			int visibleItemCount, int totalItemCount) {
		txtOverlay.setText(String.valueOf(stringArry[firstVisibleItem + (visibleItemCount >> 1)].charAt(0)).toUpperCase());  
	}

	public void onScrollStateChanged(AbsListView view, int scrollState) {
		this.scrollState = scrollState;     
        if (scrollState == ListView.OnScrollListener.SCROLL_STATE_IDLE) {     
            handler.removeCallbacks(disapearThread);     
            // ��ʾ�ӳ�1.5s����ʧ     
            handler.postDelayed(disapearThread, 1500);      
        } else {     
            txtOverlay.setVisibility(View.VISIBLE);     
        }   
	}

	public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
		MSystem.pv+=1;
//		if(arg0.getAdapter().equals(indexAdapter)){
//			String s = ((TextView)arg1).getText().toString();  
//			   txtOverlay.setText(s);  
//			   txtOverlay.setVisibility(View.VISIBLE);  
//			   handler.removeCallbacks(disapearThread);    
//			   // ��ʾ�ӳ�1.5s����ʧ     
//		       handler.postDelayed(disapearThread, 1500);   
//		       int localPosition = binSearch(stringArry,s); //���շ���ֵ  
//		       if(localPosition!=-1){  
//			     txtOverlay.setVisibility(View.INVISIBLE); //��ֹ�����ֵ�txtOverlay�����ֵ�txtOverlay��ͻ  
//		         list.setSelection(localPosition); //��Listָ���Ӧλ�õ�Item  
//			   }  
//		}else{
			
			String city=sortMap.get(webNameArr.get(position));
			MSystem.selectCity =city.replace("市", "").trim() ;
			
			if(from.equals("home")){
				 ChangeCityActivity.activity.finish();
			}else if(from.equals("today")){
				ChangeCityActivity.activity.finish();
			} else if(from.equals("buySite")){
				ChangeCityActivity.activity.finish();
			}else if(from.equals("welcom")){
				 ChangeCityActivity.activity.finish();
				Intent mIntent  = new Intent(AllCiTies.this,MainTabActivity.class);
		        startActivity(mIntent);
		        
			} 
			Toast.makeText(AllCiTies.this, "切换城市成功", 1).show();
			AllCiTies.this.finish();
			
			
//		}
		
	
	}
	
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			
			AllCiTies.this.finish();
		}
		
		// TODO Auto-generated method stub
		return super.onKeyDown(keyCode, event);
		
	}
	public static int binSearch(String[] string , String s ){  
		  for(int i=0;i<string.length;i++){  
		   if(s.equalsIgnoreCase(""+string[i].charAt(0))){ //����ִ�Сд  
		    return i;  
		   }  
		  }  
		  return -1;  
		    
		 }  
	
	 public void onDestroy() {     
         super.onDestroy();     
         // ��txtOverlayɾ��     
         txtOverlay.setVisibility(View.INVISIBLE);     
         windowManager.removeView(txtOverlay);     
     }   
	 
	

	public void onClick(View v) {
		MSystem.pv+=1;
		// TODO Auto-generated method stub
		if(v.getId()==R.id.titleLeftView){
			AllCiTies.this.finish();
		}else{
			String s = ((TextView)v).getText().toString();  
			   txtOverlay.setText(s);  
			   txtOverlay.setVisibility(View.VISIBLE);  
			   handler.removeCallbacks(disapearThread);    
			   // ��ʾ�ӳ�1.5s����ʧ     
		       handler.postDelayed(disapearThread, 1500);   
		       int localPosition = binSearch(stringArry,s); //���շ���ֵ  
		       if(localPosition!=-1){  
			     txtOverlay.setVisibility(View.INVISIBLE); //��ֹ�����ֵ�txtOverlay�����ֵ�txtOverlay��ͻ  
		         list.setSelection(localPosition); //��Listָ���Ӧλ�õ�Item  
			   } 
			
		}
		
	} 
}